import http from "@/utils/request";

export async function login(data) {
  return await http.login("/api/user/login", data);
}

export async function getInfo(token) {
  return await http.get("/api/sysUser/getInfo", null);
}

export const logout = async () => {
  return await http.post("/api/sysUser/logout");
};
// export async function logout() {
// }

export const getMenuListApi = async () => {
  return await http.get("/api/sysUser/getMenuList");
};

/**
 *  查询用户列表
 * @param {*} params
 * @returns
 */
export const getUserListApi = async (params) => {
  return await http.get("/api/user/list", params);
};

/**
 *  添加用户
 */
export const addUserApi = async (params) => {
  return await http.post("/api/user/add", params);
};

export const editUserApi = async (params) => {
  return await http.put("/api/user/update", params);
};
export const deleteUserApi = async (params) => {
  return await http.delete("/api/user/delete", params);
};

/**
 * 查询用户角色列表
 * @param params
 * @returns
 */
export const getAssignRoleListApi = async (params) => {
  return await http.get("/api/user/getRoleListAssign", params);
};
/**
 * 获取分配角色列表数据
 * @param params
 * @returns
 */
export const getRoleIdByUserIdApi = async (params) => {
  return await http.getRestApi("/api/user/getRoleByUserId", params);
};

/**
 * 分配角色
 */
export const assignRoleSaveApi = async (params) => {
  return await http.post("/api/user/saveUserRole", params);
};

/**
 *  刷新token方法
 * @param {*} params
 */
export const refreshTokenApi = async (params) => {
  return await http.post("/api/sysUser/refreshToken", params);
};
